package com.huixue.cn.ztej.constants;

import java.io.File;

import javax.servlet.http.HttpServletRequest;



public class ResourceLocator {

    /*****************************平台文件存储路径******************************/

    
	// 模板图片
	public static final String TEMPLATEIMAGE = "zt143/uploadImages";
	
	// 模板图片
	public static final String TEMPLATE_ICON = "zt143/templateIcons";
	
	//模板文件路径
	public static final String TEMPLATEFILES = "zt143/templateFiles";
	
	public static final String TEMPLATE="zt143/template";

    
    /**
     * 获取资源文件绝对路径
     * @param relateLocatin
     * @return
     */
    public static File getResourceAbsoluteLocationWin(String relateLocatin) {
        String parentPath = PropertiesUtils.getPropertiesValue("mc.resource.location.window");
        return new File(parentPath, relateLocatin);
    }
    
    public static File getResourceAbsoluteLocationLinux(String relateLocatin) {
        String parentPath = PropertiesUtils.getPropertiesValue("mc.resource.location.linux");
        return new File(parentPath, relateLocatin);
    }
    
    /**
     * 获取资源文件绝对路径
     * @param relateLocatin
     * @return
     */
    public static String getResourceAbsoluteLocationPathWin(String relateLocatin) {
        return getResourceAbsoluteLocationWin(relateLocatin).getAbsolutePath();
    }
    
    public static String getResourceAbsoluteLocationPathLinux(String relateLocatin) {
        return getResourceAbsoluteLocationLinux(relateLocatin).getAbsolutePath();
    }

    public static String getResourceAbsoluteRootPath() {
        return PropertiesUtils.getPropertiesValue("wechat.resource.location");
    }

    public static File getResourceAbsoluteRootFile() {
        return new File(getResourceAbsoluteRootPath());
    }
    
    public static String getResourceBrowseUrl(HttpServletRequest request){
    	String baseUrl = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+"/upload/zt143"; 
    	return baseUrl;
    }
    public static void main(String[] args) {
    	String absolutePath = ResourceLocator.getResourceAbsoluteLocationWin(ResourceLocator.TEMPLATEIMAGE).getAbsolutePath();
    	System.out.println(absolutePath);
    }
}
